package com.ganbo.stock.task;

import com.ganbo.stock.config.StockJobSwitchConfig;
import com.ganbo.stock.service.impl.StockService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * 定时维护股票信息
 * Created by gan on 2020/12/26 20:53.
 */

@Component
@Slf4j
public class StockJob {

    @Autowired
    StockService stockService;
    @Autowired
    StockJobSwitchConfig switchConfig;

    @Scheduled(cron = "0 */5 * * * ?")
    public void updateStockInfoTask() {
        if (switchConfig.isStockJob()) {
            log.info("获取股票标的列表 start.");
            stockService.init();
            log.info("获取股票标的列表 end.");
        }
    }

}
